const baseParam = {

}

baseParam.head = {
        "platform": "wx",
        "token": "",
        appid: ''
    }
    // const basUrl = 'http://minarole.com:28080/bmwl/mgrweb-api/'
var basUrl = 'https://wx.lingdanwang.cn/bmwl/mp-api/'
    // var  basUrl = 'https://wx.boma56.com/bmwl/mp-api/'
    // https://wx.boma56.com
export async function request(url, obj, dontLoading = true, restUrl) {
    if (restUrl) {
        basUrl = restUrl
    } else {
        // basUrl = 'https://wx.boma56.com/bmwl/mp-api/'
        basUrl = 'https://wx.lingdanwang.cn/bmwl/mp-api/'

    }
    // let token = store.state.wechat.token;

    return new Promise((resolve, reject) => {
        // 是否显示loading
        // const accountInfo = wx.getAccountInfoSync();
        baseParam.head.token = wx.getStorageSync("token") || ''
        if (dontLoading) {
            wx.showNavigationBarLoading();
            wx.showLoading({
                mask: true,
                title: '加载中...'
            });
        }
        wx.request({
            url: basUrl + url,
            data: {
                ...baseParam,
                ...obj
            },
            header: {
                token: ''
            },
            method: "POST",
            success(res) {
                wx.hideLoading();
                wx.hideNavigationBarLoading();
                resolve(res.data)
            },

            fail(e) {
                wx.hideLoading();
                wx.hideNavigationBarLoading();
                reject(e)
            }

        })
    })
}
export default request